import React, {FC} from "react";
import BreadcrumbPath from "../../../components/BreadcrumbPath";
import {Button, Col, Form, Input, message, Row, Select} from "antd";
import api from "../../../api";
import {useNavigate} from "react-router-dom";

const AddInterview: FC = () => {

    const [form] = Form.useForm();

    const navigate = useNavigate();

    return (
        <div>
            {/*<h1>发布言论</h1>*/}
            <BreadcrumbPath/>
            <Form
                style={{width: '40%', backgroundColor: '#fff', padding: '20px', borderRadius: "10px",}}
                name="basic"
                form={form}
                layout='vertical'
                onFinish={(values) => {
                    console.log(values);
                    api.addInterview(values).then(res => {
                        message.success(res.msg);
                        form.resetFields();
                        navigate('/main/interview/interviewList');
                    }).catch(err => {
                        message.error(err);
                    })
                }}
            >
                <Form.Item
                    label="标题"
                    name="title"
                    rules={[{required: true, message: '标题不能为空!'}]}
                >
                    <Input placeholder="请输入标题"/>
                </Form.Item>
                <Form.Item
                    label="内容"
                    name="content"
                    rules={[{required: true, message: '内容是必填的!'}]}
                >
                    <Input.TextArea placeholder="请输入内容" showCount rows={6}/>
                </Form.Item>
                <Form.Item>
                    <Button block size="large" type="primary" htmlType="submit">发布</Button>
                </Form.Item>
            </Form>
        </div>
    );
};

export default AddInterview;